package com.example.asus.testskip.DGPhone.phone;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.telephony.TelephonyManager;
import android.util.Log;

/* renamed from: dg.ca.com.DGPhone.phone.PhoneStateReceiver */
public class PhoneStateReceiver extends BroadcastReceiver {
    private static final Object monitor = new Object();

    /* renamed from: a */
    private int f27a = 0;
    private TelephonyManager telMgr = null;


    private void showActivity(Context ctx, String number) {
        Intent intent = new Intent(ctx, OverLayActivity.class);
        intent.addFlags(268435456);
        intent.putExtra("phoneNum", number);
        ctx.startActivity(intent);
    }

    /* access modifiers changed from: private */
    public void showWindow(Activity ctx, String number, int percentScreen) {
        OverlayView.show(ctx, number, percentScreen);
    }

    /* access modifiers changed from: private */
    public void closeWindow(Context ctx) {
        OverlayView.hide(ctx);
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        final Context ctx = context;
        this.telMgr = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
        Log.i("我的信息", "overlay CALL_STATE_RINGING:" + this.telMgr.getCallState());
        switch (this.telMgr.getCallState()) {
            case 0:
                synchronized (PhoneStateReceiver.this) {
                    new Handler().postDelayed(new Runnable() {
                        public void run() {
                            Log.i("我饿的信息", "overlay CALL_STATE_RINGING");
                            PhoneStateReceiver.this.closeWindow(ctx);
                        }
                    }, 500);
                }
                return;
            case 1:
                System.out.println("....................涓讳汉锛岄偅瀹朵紮鍙堟潵鐢佃瘽浜�....................");
                Log.i("我饿的信息", "overlay CALL_STATE_RINGING");
                final String number = intent.getStringExtra("incoming_number");
                System.out.println("number:" + number);
                if (number != null) {
                    synchronized (monitor) {
                        new Handler().postDelayed(new Runnable() {
                            public void run() {
                                Log.i("我饿的信息", "overlay CALL_STATE_RINGING");
//                                PhoneStateReceiver.this.showWindow(ctx, number, 100);
                            }
                        }, 1000);
                    }
                    return;
                }
                return;
            default:
                return;
        }
    }
}
